#include<iostream>
using namespace std;
int n;
int main()
{
	while (cin >> n)
	{
		if (n < 2) break;
		int res = 0;
		while (n > 2)
		{
			res += n / 3;
			n = n / 3 + n % 3;
		}
		if (n == 2) res++;
		cout << res << endl;
	}
	return 0;
}